home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Herois
/
Codigo.Cst
/
00062_Script_PopUp Busca Drag
< prev
next >
Wrap
Text File
|
1999-03-19
|
22KB
|
659 lines
property spr
property spriteList, len -- Sprites a serem movidos juntos
property editableList
property permiteIdle
property ligado, escondido
property animaSprite, animaPrim, animaUlt, animaTimer, animaVelocidade
property memPrim, memUlt, memAtual
property critico, estado
property menu, menuItem, sprMenu
property memoria, animaPrim2, animaUlt2
on getBehaviorDescription
return "Arrasta sprites com o mouse e anima"
end
on getPropertyDescriptionList
set p_list = [ ¼
#spriteList: [ #comment: "Lista de sprites a serem arrastados", ¼
#format: #list, ¼
#default: [0] ], ¼
#editableList: [ #comment: "Sprites editaveis que devem ser desligados antes de serem arrastados",¼
#format: #list,¼
#default: [] ],¼
#permiteIdle: [ #comment: "Permite funcionamento de outros sprites durante arraste", ¼
#format: #boolean, ¼
#default: false ], ¼
#animaSprite: [ #comment: "Sprite sendo animado", ¼
#format: #integer, ¼
#default: 0 ], ¼
#animaVelocidade: [ #comment: "Tempo (em ticks) entre cada animacao", ¼
#format: #integer, ¼
#default: 30 ], ¼
#animaPrim: [ #comment: "Primeiro membro da animacao",¼
#format: #string,¼
#default: "" ],¼
#animaUlt: [ #comment: "Ultimo membro da animacao", ¼
#format: #string, ¼
#default: "" ], ¼
#memoria: [ #comment: "Limite de memoria pequena", ¼
#format: #integer, ¼
#default: 0 ], ¼
#animaPrim2: [ #comment: "Primeiro membro da animacao (low mem)",¼
#format: #string,¼
#default: "" ],¼
#animaUlt2: [ #comment: "Ultimo membro da animacao (low mem)", ¼
#format: #string, ¼
#default: "" ] ¼
]
return p_list
end
-- Guarda count para acesso rapido
on beginSprite me
global myMemSize
set spr = the spriteNum of me
put count(spriteList) into len
set ligado = true
if myMemSize > memoria * 1024 * 1024 then
set memPrim = the number of member animaPrim
set memUlt = the number of member animaUlt
else
set memPrim = the number of member animaPrim2
set memUlt = the number of member animaUlt2
end if
set memAtual = memPrim
puppetSprite animaSprite, true
set critico = false
set estado = 0
set menu = false
set menuItem = 0
set sprMenu = 107
set the visibility of sprite sprMenu to false
set the visibility of sprite sprMenu + 1 to false
end
-- Esconde menu
on chaveEsconde me, liga
if (liga = escondido) or not ligado then return
set escondido = liga
if escondido then
chaveEditaveis me, false
chaveMenu me, false
puppetSprite 97, true
set m = the number of the member of sprite 97
set the member of sprite 97 to member (m+1)
set the visibility of sprite 98 to false
repeat with i = 1 to len
put getAt(spriteList,i) into s
if s < sprMenu and s <> spr and s <> 105 then
set the locV of sprite s to (the locV of sprite s) + 960
end if
end repeat
else
chaveEditaveis me, true
chaveMenu me, false
set m = the number of the member of sprite 97
set the member of sprite 97 to member (m-1)
repeat with i = 1 to len
put getAt(spriteList,i) into s
if s < sprMenu and s <> spr and s <> 105 then
set the locV of sprite s to (the locV of sprite s) - 960
end if
end repeat
if estado = 0 then set the visibility of sprite 98 to true
end if
end
-- Liga ou desliga sprites
on chaveMenu me, liga
if liga = menu then return
set menu = liga
set menuItem = 0
if menu then
set the visibility of sprite sprMenu to true
set the visibility of sprite 98 to false
else
set the visibility of sprite sprMenu to false
set the visibility of sprite sprMenu+1 to false
if estado = 0 and not escondido then set the visibility of sprite 98 to true
end if
end
-- Liga ou desliga sprites
on clicaMenu me
if menuItem = 0 then return
set tmp = menuItem - 1
chaveMenu me, false
setEstado me, tmp
end
-- Liga ou desliga sprites
on chaveVisibilidade me, liga
if liga = ligado then return
if liga then
chaveEditaveis me, true
repeat with i = 1 to len
put getAt(spriteList,i) into s
set the locV of sprite s to (the locV of sprite s) - 960
end repeat
if estado = 0 and not escondido then
set the visibility of sprite 98 to true
end if
set ligado = true
set animaTimer = the timer
else
chaveMenu me, false
chaveEditaveis me,false
repeat with i = 1 to len
put getAt(spriteList,i) into s
set the locV of sprite s to (the locV of sprite s) + 960
end repeat
set the visibility of sprite 98 to false
set ligado = false
end if
end
-- Desloca todos os componetes do popup
on moveRelativo me, dx, dy
repeat with i = 1 to len
put getAt(spriteList,i) into s
set the locH of sprite s to (the locH of sprite s) + dx
set the locV of sprite s to (the locV of sprite s) + dy
end repeat
end
-- Liga/desliga campos editaveis: recomenda-se update stage
-- depois
on chaveEditaveis me, liga
put count(editableList) into l
repeat with i=1 to l
set the editable of sprite getAt(the editableList of me,i) to liga
end repeat
end
on mouseDown me
-- Verifica se esta em area sensivel para arraste
set mh = the mouseH - the locH of sprite spr
set mv = the mouseV - the locV of sprite spr
set mp = point(mh,mv)
if inside(mp,rect(-87,-121,86,-107)) then
-- Pega posicoes iniciais
put the mouseH into iniX
put the mouseV into iniY
-- Desliga editaveis
chaveEditaveis me, false
if count(the editableList of me) > 0 then updateStage
-- Loop enquanto pessoa segura mouse
repeat while the mouseDown
if the mouseV <> iniY or the mouseH <> iniX then
put the mouseV into mY
put the mouseH into mX
moveRelativo me, mX - iniX, mY - iniY
updateStage
put mY into iniY
put mX into iniX
end if
if permiteIdle then SendAllSprites(#IdleSprite)
end repeat
-- Liga editaveis
chaveEditaveis me, true
if count(the editableList of me) > 0 then updateStage
end if
end
on mouseUp me
set mh = the mouseH - the locH of sprite spr
set mv = the mouseV - the locV of sprite spr
set mp = point(mh,mv)
if inside(mp, rect(86,-121,102,-105)) then
-- Botao de esconde
puppetSound 2,"Esconde"
chaveEsconde me, not escondido
else if inside(mp, rect(34, -117, 85, -108)) then
-- Botao de abrir submenu
puppetSound 2, "SomCliqueSimples"
chaveMenu me, not menu
updateStage
else if inside(mp, rect(77,94,100,118)) then
-- Testa botao de incluir pagina atual
if testaPagina() then
global gPagSel
set m = the member of sprite 106
set the member of sprite 106 to member "CliquePagina1"
updateStage
set t = the timer
set pag = paginaAtual()
if getPos(gPagSel,pag) <= 0 then add gPagSel, pag
if estado = 2 then
sendSprite(100,#listaSelecionados)
set the foreColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoBranco") -- white
set the backColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoPreto") -- black
sendSprite 104, #move, 0
updateStage
end if
set the member of sprite 106 to m
updateStage
end if
else if inside(mp, rect(-55, 72, -43, 88)) then
-- Testa se tem paginas a sair ou entrar nas selecionadas
global gPagSel
if estado <> 2 then
set m = the member of sprite 106
set the member of sprite 106 to member "CliquePagina1"
updateStage
set t = the timer
if the doubleClick and estado = 0 then
puppetSound 2,"CliqueInclui"
-- Adiciona todas paginas a lista de selecionadas
repeat with i = 1 to count(the intIndicePaginas of sprite 100)
set pag = getAt(the intIndicePaginas of sprite 100,i)
if getPos(gPagSel,pag) <= 0 then add gPagSel, pag
end repeat
else if the intPalavraClicada of sprite 100 <> 0 then
puppetSound 2,"CliqueInclui"
-- Adiciona pagina a lista de selecionadas
if estado = 0 then
set pag = getAt(the intIndicePaginas of sprite 100,¼
the intPalavraClicada of sprite 100)
else
set pag = Integer(item (the intPalavraClicada of sprite 100)¼
of field "ListaAlfabeticaRef")
end if
if getPos(gPagSel, pag) <= 0 then add gPagSel, pag
--
end if
repeat while the timer - t < 8
end repeat
set the member of sprite 106 to m
updateStage
else
set m = the member of sprite 106
set the member of sprite 106 to member "CliquePagina2"
set t = the timer
if the doubleClick then
puppetSOund 2,"CliqueExclui"
set gPagSel = []
sendSprite(100,#listaSelecionados)
set the foreColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoBranco") -- white
set the backColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoPreto") -- black
sendSprite 104, #move, 0
updateStage
else if the intPalavraClicada of sprite 100 <> 0 then
puppetSOund 2,"CliqueExclui"
-- Remover pagina da lista de selecionados
set pag = getAt(the intIndicePaginas of sprite 100,¼
the intPalavraClicada of sprite 100)
deleteOne gPagSel, pag
sendSprite(100,#listaSelecionados)
set the foreColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoBranco")-- white
set the backColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoPreto")-- black
sendSprite 104, #move, 0
updateStage
end if
repeat while the timer - t < 8
end repeat
set the member of sprite 106 to m
updateStage
end if
-- Testa mudanca de estados
else if inside(mp,rect(-56,14,-38,35)) or inside(mp,rect(-87,55,-80,112)) then
setEstado me, 0
else if inside(mp, rect(-53,41,-39,55)) then
setEstado me, 1
else if inside(mp, rect(-73,86,-53,100)) or¼
inside(mp,rect(-57,59,-38,93)) then
setEstado me, 2
else
global eMac
if estado = 1 then
-- Letras
if mv >= -105 and mv <= -92 and mh >= -34 and mh <= 96 then
set tmp = 0
-- a - n
if mh < - 21 then
set tmp = 1
else if mh < -13 then
if eMac then set tmp = 62
else set tmp = 63
else if mh < -3 then
if eMac then set tmp = 128
else set tmp = 129
else if mh < 5 then
if eMac then set tmp = 229
else set tmp = 231
else if mh < 15 then
if eMac then set tmp = 301
else set tmp = 303
else if mh < 23 then
if eMac then set tmp = 334
else set tmp = 336
else if mh < 33 then
if eMac then set tmp = 371
else set tmp = 373
else if mh < 42 then
if eMac then set tmp = 411
else set tmp = 414
else if mh < 50 then
if eMac then set tmp = 463
else set tmp = 467
else if mh < 57 then
if eMac then set tmp = 476
else set tmp = 480
else if mh < 66 then
if eMac then set tmp = 552
else set tmp = 556
else if mh < 73 then
if eMac then set tmp = 594
else set tmp = 599
else if mh < 85 then
if eMac then set tmp = 629
else set tmp = 634
else
if eMac then set tmp = 730
else set tmp = 736
end if
else if mv >= -90 and mv <= -78 and mh >= -34 and mh <= 83 then
-- o - z
if mh < -21 then
if eMac then set tmp = 761
else set tmp = 768
else if mh < -13 then
if eMac then set tmp = 774
else set tmp = 781
else if mh < -3 then
if eMac then set tmp = 820
else set tmp = 828
else if mh < 6 then
if eMac then set tmp = 824
else set tmp = 832
else if mh < 15 then
if eMac then set tmp = 882
else set tmp = 891
else if mh < 23 then
if eMac then set tmp = 1014
else set tmp = 1025
else if mh < 32 then
if eMac then set tmp = 1068
else set tmp = 1079
else if mh < 42 then
if eMac then set tmp = 1095
else set tmp = 1106
else if mh < 52 then
if eMac then set tmp = 1115
else set tmp = 1126
else if mh < 64 then
if eMac then set tmp = 1130
else set tmp = 1141
else if mh < 73 then
if eMac then set tmp = 1136
else set tmp = 1147
else if mh < 83 then
if eMac then set tmp = 1140
else set tmp = 1151
end if
end if
-- Faz scroll
if tmp <> 0 then sendSprite 100, #scrollLinha, tmp
end if
end if
end
on idleSprite me
global gMustUpdate
if menu then
if (not rollOver(sprMenu)) then
if (not rollOver(spr)) or ¼
(the mouseV - the locV of sprite spr) > -103 then
chaveMenu me, false
else if menuItem <> 0 then
set menuItem = 0
set the visibility of sprite sprMenu+1 to false
set gMustUpdate to true
end if
else
set tmp = ((the mouseV - the locV of sprite sprMenu) + 104) / 14
set tmp = tmp + 1
if tmp > 3 then set tmp = 3
else if tmp < 1 then set tmp = 1
if tmp <> menuItem then
set menuItem = tmp
puppetSprite sprMenu + 1, true
set the member of sprite sprMenu+1 to member (the number of member "BuscaMenuItens" + menuItem - 1)
set the visibility of sprite sprMenu + 1 to true
set gMustUpdate = true
end if
end if
else if ligado and rollOver(spr) then
if the timer > animaTimer + animaVelocidade and memPrim <> memUlt then
-- Indica trecho critico (incrementando gCritico) e
-- marca localmente em <critico>
if not critico then
set critico = true
global gCritico
set gCritico = gCritico + 1
end if
-- set memAtual = memAtual + 1
-- if memAtual > memUlt then set memAtual = memPrim
set memAtual = random(memUlt - memPrim + 1) + memPrim + 1
set the member of sprite animaSprite to member memAtual
set gMustUpdate = true
set animaTimer = the timer
end if
else
-- Se nao esta animando, mas critico ainda estiver ligado,
-- desliga critico, e volta gCritico ao original
if critico then
global gCritico
set critico = false
set gCritico = gCritico -1
end if
end if
end
on setEstado me, num
-- Testa se precisa mudar
if estado = num then return
chaveMenu me, false
-- Estado 1, lista alfabetica
if num = 2 then
if estado = 0 then
-- De 0 -> 2
-- Acerta/apaga sprites
puppetSprite spr, true
set tmp = the number of member "PopUpBuscaSelecionados"
if escondido then set tmp = tmp + 1
set the member of sprite 97 to member tmp
set the visibility of sprite 98 = false
set the visibility of sprite 99 = false
set the visibility of sprite 101 = false
set the visibility of sprite 102 = false
-- Barra de scroll
set the locV of sprite 103 to (the locV of sprite 103) - 104
set the height of sprite 103 to 198
-- Texto: lista alfabetica
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "PaginasSelecionadas"
sendSprite(100,#listaSelecionados)
set the foreColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoBranco") -- white
set the backColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoPreto") -- black
set the locV of sprite 100 to (the locV of sprite 100) - 104
set the height of sprite 100 to 192
set the visibility of sprite 100 to true
sendSprite 104, #move, 0
updateStage
else if estado = 1 then
-- De 1 -> 2
set tmp = the number of member "PopUpBuscaSelecionados"
if escondido then set tmp = tmp + 1
set the member of sprite 97 to member tmp
set the locV of sprite 103 to (the locV of sprite 103) - 30
set the height of sprite 103 to 198
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "PaginasSelecionadas"
sendSprite(100,#listaSelecionados)
set the foreColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoBranco") -- white
set the backColor of member "PaginasSelecionadas" to ¼
(the backColor of member "FundoPreto") -- black
set the locV of sprite 100 to (the locV of sprite 100) - 30
set the height of sprite 100 to 192
set the visibility of sprite 100 to true
sendSprite 104, #move, 0
updateStage
end if
else if num = 1 then
if estado = 0 then
-- De 0 -> 1
-- Acerta/apaga sprites
puppetSprite spr, true
set tmp = the number of member "PopUpBuscaAlfabetica"
if escondido then set tmp = tmp + 1
set the member of sprite 97 to member tmp
set the visibility of sprite 98 = false
set the visibility of sprite 99 = false
set the visibility of sprite 101 = false
set the visibility of sprite 102 = false
-- Barra de scroll
set the locV of sprite 103 to (the locV of sprite 103) - 74
set the height of sprite 103 to 168
-- Texto: lista alfabetica
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "ListaAlfabetica"
sendSprite(100,#listaTodos)
set the locV of sprite 100 to (the locV of sprite 100) - 74
set the height of sprite 100 to 162
set the visibility of sprite 100 to true
sendSprite 104, #move, 0
updateStage
else if estado = 2 then
-- De 2 -> 1
set tmp = the number of member "PopUpBuscaAlfabetica"
if escondido then set tmp = tmp + 1
set the member of sprite 97 to member tmp
set the locV of sprite 103 to (the locV of sprite 103) + 30
set the height of sprite 103 to 168
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "ListaAlfabetica"
sendSprite(100,#listaTodos)
set the locV of sprite 100 to (the locV of sprite 100) + 30
set the height of sprite 100 to 162
set the visibility of sprite 100 to true
sendSprite 104, #move, 0
updateStage
end if
-- Estado 0, lista generica
else
if estado = 2 then
-- De 2 -> 0
-- Acerta/acende sprites
puppetSprite spr, true
set tmp = the number of member "PopUpBuscaGenerica"
if escondido then set tmp = tmp + 1
set the member of sprite 97 to member tmp
set the visibility of sprite 98 = true
set the visibility of sprite 99 = true
set the visibility of sprite 101 = true
set the visibility of sprite 102 = true
-- Barra de scroll
set the locV of sprite 103 to (the locV of sprite 103) + 104
set the height of sprite 103 to 94
-- Texto: lista alfabetica
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "PaginasGenerico"
set the locV of sprite 100 to (the locV of sprite 100) + 104
set the height of sprite 100 to 88
set the visibility of sprite 100 to true
sendSprite 100, #zera
updateStage
-- De 1 -> 0
else if estado = 1 then
set tmp = the number of member "PopUpBuscaGenerica"
if escondido then set tmp = tmp + 1
set the member of sprite spr to member tmp
set the visibility of sprite 98 to true
set the visibility of sprite 99 to true
set the visibility of sprite 101 to true
set the visibility of sprite 102 to true
-- Barra de scroll
set the locV of sprite 103 to (the locV of sprite 103) + 74
set the height of sprite 103 to 94
-- Texto
set the visibility of sprite 100 to false
updateStage
sendSprite 100, #setMembro, "PaginasGenerico"
set the locV of sprite 100 to (the locV of sprite 100) + 74
set the height of sprite 100 to 88
set the visibility of sprite 100 to true
sendSprite 100, #zera
updateStage
end if
end if
-- Finalmente seta novo estado
set estado = num
end